package com.chinasofti.shoot;

import java.awt.image.BufferedImage;

//飞行物
public abstract class FlyingObject {
    protected BufferedImage image; //图片
    protected int width;
    protected int height;
    protected int x;//坐标
    protected int y;//坐标

    //飞行物
    public abstract void step();

    //判断飞行物会否越界
    public abstract boolean  outOfBounds();
    //敌人被子弹射击
    public boolean shootBy(Bullet bullet){
        int x1 = this.x;//x1 敌机的x
        int x2 = this.x + this.width;//x2 敌机的x+敌人的宽
        int y1 = this.y;//y1 敌机的y
        int y2 = this.y + this.height;//y2 敌机的y+敌机高
        int x = bullet.x;// x 子弹的x
        int y = bullet.y;//y子弹的y
        return x >x1 && x <x2
                &&
                y>y1 && y<y2;

    }

}



